module ApplicationHelper
  def edit_image(declaration)
    if declaration.editable? current_user
      button({:controller => 'declarations', :action => 'edit', :id => declaration.id})
    end
  end

  def button(options = {}, icon = 'edit')
    link_to image_tag("icons/#{icon}.gif", :alt => 'Editable'), options, :class => 'button'
  end
  
  def print_additional_persons(nr)
    nr = nr.to_i
    if nr < 1
      return "Geen extra personen"
    elsif nr == 1
      return "1 extra persoon"
    else
      return "#{nr} extra personen"
    end
  end
  
  def print_additional_persons_with_edit(user_id, nr_of_additional_persons)
    nr = nr.to_i
    user_id = user_id.to_i
    text_field_tag "declaration_payers[#{user_id}]", nr_of_additional_persons, :size => 12
  end
  
  def init_ajax_module_balans
    apply_behaviour 'body',
      remote_function(
      :update => "module_balans",
      :url => { :controller => 'ajax', :action => 'module_balans' },
      :loading => "$('module_balans').addClassName('progress_indicator');",
      :complete => "$('module_balans').removeClassName('progress_indicator');"
    )
  end
  
end